package com.goods.business.converter;

import com.goods.common.model.business.ProductCategory;
import com.goods.common.vo.business.ProductCategoryTreeNodeVO;
import com.goods.common.vo.business.ProductCategoryVO;
import com.goods.common.vo.business.SupplierVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**********************
 *
 *@Author 闫星忠
 *@Time 2021/12/15  12:52
 *
 */
public class ProductCategoryConverter {

    /**
     * ProductCategoryList转成ProductCategoryTreeNodeVOList
     */

    public static List<ProductCategoryTreeNodeVO> converterToProductCategoryTreeNodeVO(List<ProductCategory> productCategories){
        List<ProductCategoryTreeNodeVO> productCategoryTreeNodeVOS = new ArrayList<>();
        if (!CollectionUtils.isEmpty(productCategories)){
            for (ProductCategory productCategory : productCategories){
                ProductCategoryTreeNodeVO productCategoryTreeNodeVO = new ProductCategoryTreeNodeVO();
                BeanUtils.copyProperties(productCategory,productCategoryTreeNodeVO);
                productCategoryTreeNodeVOS.add(productCategoryTreeNodeVO);
            }
        }

        return productCategoryTreeNodeVOS;
    }

    public static ProductCategoryVO converterToProductCategoryVO(ProductCategory productCategory){
        ProductCategoryVO productCategoryVO = new ProductCategoryVO();
        BeanUtils.copyProperties(productCategory,productCategoryVO);
        return productCategoryVO;
    }
}
